<?php

/**
 * Description de la classe Service DATA
 */
class ServicesData {

    /**
     * Retourne les données de services d'un projet
     * @param type $id
     * @return type
     */
    public static function getServicesData($id) {
        $query = mysql_query("SELECT id_services_data, station_id, date, type, code, event FROM wsk_services_data WHERE id_services_data = $id");
        $list = array();
        while ($row = mysql_fetch_assoc($query)) {
            foreach ($row as $k => $v) {
                if ($k != 'date') {
                    $list['services_data'][$k] = $v;
                } else {
                    // Si le numéro du jour ne commence pas par un 0
                    if (strlen($v) == 13) {
                        $v = '0' . $v;
                    }

                    $date = DateTime::createFromFormat('dmYHis', $v);
                    $list['services_data'][$k] = $date->format('d M Y H:i:s');
                }
            }
        }
        mysql_free_result($query);

        return $list;
    }

}

?>